﻿using GEPL.InterfaceLibrary;
using GEPL.StandardModulesLibrary.ViewModels.Turtle;
using GEPL.StandardModulesLibrary.Views.Turtle;
using System;
using System.Runtime.Serialization;

namespace GEPL.StandardModulesLibrary.Elements.Turtle
{
    [Serializable]
    public class TurtleShowHideElement : IElement
    {
        private readonly TurtleShowHideViewModel viewModel;

        public TurtleShowHideElement()
        {
            viewModel = new TurtleShowHideViewModel();
        }

        public TurtleShowHideElement(SerializationInfo info, StreamingContext context)
        {
            viewModel = new TurtleShowHideViewModel()
            {
                Show = info.GetBoolean(nameof(viewModel.Show)),
                Hide = info.GetBoolean(nameof(viewModel.Hide))
            };
        }

        public ElementType ElementType
        {
            get { return ElementType.NormalStatement; }
        }

        public ProjectType ProjectType
        {
            get { return ProjectType.TurtleGraphics; }
        }

        public string ElementName
        {
            get { return Properties.Resources.Names_TurtleShowHide; }
        }

        public object Data
        {
            get { return viewModel; }
        }

        public Type UserControlType
        {
            get { return typeof(TurtleShowHideView); }
        }

        public string GetScript()
        {
            return viewModel.Show ? "Turtle.ShowTurtle()" : "Turtle.HideTurtle()";
        }

        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue(nameof(viewModel.Show), viewModel.Show);
            info.AddValue(nameof(viewModel.Hide), viewModel.Hide);
        }
    }
}